<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>流媒体视频管理平台-客户端视频分配</title>

		<link href="js/jquery-ui-1.8.17.custom.css" rel="stylesheet"
			type="text/css" />
		<link href="css/site.css" rel="stylesheet" type="text/css" />
		<SCRIPT type="text/javascript" src="js/jquery-1.5.1.min.js"></SCRIPT>
		<SCRIPT type="text/javascript" src="js/jquery-ui.js"></SCRIPT>
		<SCRIPT type="text/javascript">
			var clientID = "";
			$(document).ready(function() {
				var url = "GetVoteList.action";
				$.ajax( {
					url : url,
					type : "POST",
					cache:false,
					dataType : "json",
					success : function(data) {
						$("#voteHolder").html(data);
					},
					error : function(ee) {
						alert('服务器错误');
					}
				});
			});
		
			function ShowVotePanel(id) {
				clientID = id;
				$("[type='checkbox']", $("#VideoHolder")).attr("checked", false);
				$.ajax( {
					url : "GetClientVideoArray.action",
					type : "POST",
					cache:false,
					data : {
						"adminID" : id
					},
					dataType : "json",
					success : function(data) {
						var result = data;
						var aa = result.split(',');
						$(aa).each(function() {
							$("#video_" + this).attr("checked", true);
						});
					},
					error : function(ee) {
						alert('服务器错误');
					}
				});
				$("#videoPanel").dialog( {
					height : 400,
					width : 700,
					modal : true,
					title : "指定客户端视频"
				});
			}
			function Save() {
				var videoID = "";
				var checkbox = $("[type='checkbox']", $("#VideoHolder"));
				$(checkbox).each(function() {
					if ($(this).attr("checked")) {
						videoID = videoID + $(this).val() + ","; // 权限用逗号隔开，传递到后台数据库进行拆解
		
					}
				});
		
				var url = "SaveClientVideoArray.action";
				var params = {
					"adminID" : clientID,
					"videoArray" : videoID
				};
				$.ajax( {
					url : url,
					data : params,
					type : "POST",
					cache:false,
					dataType : "json",
					success : function(data) {
						if (data == 'true') {
							alert('赋权成功');
							$("#videoPanel").dialog('close');
						} else {
							alert('赋权失败');
							$("#videoPanel").dialog('close');
						}
					},
					error : function(ee) {
						alert('服务器错误');
					}
				});
			}
		</SCRIPT>

	</head>

	<body>
		<table
			style="height: 93px; text-align: center; margin: auto; width: 100%;">
			<tr>
				<td>
					<div
						style="text-align: right; width: 900px; height: 50px; padding-top: 23px; background-image: url('images/img/index_02_04.png'); background-repeat: no-repeat;">

						<br />
						<span class="mail" style="height: 36px">xiaonirun@163.com</span>
					</div>
					<div
						style="text-align: right; width: 900px; height: 30px; padding-top: 5px; padding-left: -30px;">
						<ul id="Menu">
							<li>
								<a href="videoMark.action">视频审核</a>
							</li>
							<li>
								<a href="clientMark.action">客户端审核</a>
							</li>
							<li>
								<a href="manager/upload.jsp">上传下载</a>
							</li>
							<li>
								<a href="voteMgr.action">权限管理</a>
							</li>
							<li>
								<a href="clientVideo.action">客户端视频分配</a>
							</li>
							<li>
								<a href="LoginOut.action">退出登录</a>
							</li>
						</ul>
					</div>

					<div class="mainHolder">
						<div
							style="text-align: left; width: 900px; font-size: 20px; padding-top: 15px; padding-left: 30px;">
							<div style="float: left">
								当前位置:客户端视频分配
							</div>
							<br>
						</div>
						<hr />
						<div
							style="text-align: left; 100%; font-size: 20px; padding-top: 10px; ">
							<s:set name="clientList" value="#request.clientList" />
							<table id="mytable" border="0" width="100%" cellspacing="0"
								cellpadding="5">
								<tr bgcolor="#FAFCF5">
									<td style="border: 1 solid">
										<table border="0" width="100%" cellspacing="0" cellpadding="0">
											<tr>
												<th>
													操作
												</th>
												<th>
													客户端名称
												</th>
												<th>
													注册时间
												</th>
												<th>
													备注
												</th>
											</tr>
											<s:if test="#clientList==null||#clientList.size()==0">
												<tr height="30">
													<td colspan=4 align="center" style="border: 1 solid">
														暂无待审核的客户端注册信息
													</td>
												</tr>
											</s:if>
											<s:else>
												<s:iterator status="videoStatus" value="clientList">

													<tr height="23" id="<s:property value="id" />">
														<td>
															<a onclick="ShowVotePanel('<s:property value="id" />')">视频分配</a>
														</td>
														<td>
															<s:property value="clientName" />
															&nbsp;
														</td>
														<td>
															<s:property value="registerDate" />
															&nbsp;
														</td>
														<td>
															<s:property value="remark" />
															&nbsp;
														</td>
														<%--如果当前行的状态为偶数，则添加TR标签进行换行 --%>
														<s:if test="#videoStatus.even">
													</tr>
													</s:if>
												</s:iterator>
											</s:else>
										</table>
									</td>
								</tr>
							</table>
						</div>
					</div>
				</td>
			</tr>
		</table>
		<div id="videoPanel" style="display: none;height:300px">
			<div style="width: 100%; background-color: Menu; text-align: left;">
				选择视频
			</div>
			<div id="VideoHolder">
				<s:set name="videoList" value="#request.videoList" />
				<table id="mytable" border="0" width="100%"  cellspacing="0"
					cellpadding="1">
					<tr bgcolor="#FAFCF5">
						<td style="border: 1 solid">
							<table border="0" width="100%" cellspacing="0" cellpadding="0">
								<s:if test="#videoList==null||#videoList.size()==0">
									<tr height="30">
										<td colspan=3 align="center" style="border: 1 solid">
											暂无上传视频
										</td>
									</tr>
								</s:if>
								<s:else>
									<tr>
										<th style="width: 20px">&nbsp;</th>
										<th>
											视频分类
										</th>
										<th>
											视频名称
										</th>
										<th>
											上传时间
										</th>
									</tr>
									<s:iterator status="payforStatus" value="videoList">
										<tr>
											<%--如果当前行的状态为奇数，则添加TR标签--%>
											<s:if test="#payforStatus.odd">
												<tr height="23">
											</s:if>
											<td>
												<input type="checkbox" id="video_<s:property value="id" />"
													value="<s:property value="id" />" />
											</td>
											<td width="120px">
												<s:property value="getCategoryName()" />
											</td>
											<td>
												<a href="#"
													onclick="javascript:alert('<s:property value="name" />')">
													<s:property value="name" /> </a>
											</td>
											<td>
												<s:property value="getMyUploadTime()" />
											</td>
										</tr>
									</s:iterator>
								</s:else>
							</table>
						</td>
					</tr>
				</table>
			</div>
			<div style="width: 100%; background-color: Menu; text-align: center;font-size:0.8em">
				<input type="button" value="保存" onclick="Save()" />
			</div>
		</div>
	</body>
</html>
